#ifndef USERMANAGER_H
#define USERMANAGER_H

#include <QString>

class UserManager {
public:
    enum Role { SystemAdmin, BusinessAdmin, User, Unlogin };

    static UserManager& getInstance() {
        static UserManager inst;
        return inst;
    }

    UserManager(const UserManager&) = delete;
    UserManager& operator=(const UserManager&) = delete;

    void setUserInfo(const QString &username, const QString &password, Role role) {
        this->username = username;
        this->password = password;
        this->role = role;
        this->login = (role != Unlogin);
    }

    void resetUserInfo() {
        this->username.clear();
        this->password.clear();
        this->role = Unlogin;
        this->login = false;
    }

    QString getUsername() const { return username; }
    QString getPassword() const { return password; }
    Role getRole() const { return role; }
    bool isLogin() const { return login; }

private:
    UserManager()
        : role(Unlogin)
        , login(false)
    {}

    QString username;
    QString password;
    Role role;
    bool login;
};

#endif // USERMANAGER_H
